package com.bean;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.listener.DownloadListener;
import com.util.DBUtil;
import com.util.FileDownLoad;
import lombok.Data;

import java.util.List;
import java.util.Map;

/**
 * @author Smile
 */
@Data
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY, getterVisibility = JsonAutoDetect.Visibility.NONE)
public class DocDossierFileCatalog {
    private String NodeNo;

    private String NodeParentNo;

    private String BMSAH;

    private String TYSAH;

    private String SFSC;

    private String FQDWBM;

    private String FQL;

    private String ZHXGSJ;

    private String CJSJ;

    private String DWBM;

    private String JZMLH;

    private String WSBH;

    private String XGRQ;

    private String WJMC;

    private String WJLX;

    private String WSCFLJ;

    private String FWSBH;

    private String NZRGH;

    private String NZRXM;

    private String WJKZM;

    private String RJSJ;

    private String RJRGH;

    private String RJRXM;

    private String WJSX;

    private String GXYWBMS;

    private String SFKYGX;

    private String WSMBBH;

    private String YZBH;

    private String YZMC;

    private String YYZT;

    private String DYZT;

    private String YYHWJBH;

    private String YJDYFS;

    private String BYZDYFS;

    private String WH;

    private String SFLXSC;

    private String SCPH;

    private String PDF;

    private Map<Integer, String> IMG;

    private String TEXT;

    private String NodeName;

    public boolean download(DBUtil dbUtil, DownloadListener listener) throws Exception {
        DownloadListener.Download download = new DownloadListener.Download();
        download.setSuccess(true);
        download.setID(this.NodeNo);
        try {
            List<SQLiteArgument> sqLiteArguments = FileDownLoad.downLoadDocDossierFile(this);
//        WebSocket.sendInfo(soketID, this.getWJMC() + "下载完成...");
            if (listener != null) {
                listener.download(download);
            }
            return dbUtil.executeUpdate(sqLiteArguments);
        } catch (Exception e) {
            if (listener != null) {
                download.setSuccess(false);
                download.setMessage(e.getMessage());
                listener.download(download);
            }
            throw e;
        }
    }
}
